package com.tang.sharding.schedule.task.hook;

import com.tang.sharding.schedule.task.manager.AbstractTaskManager;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Tang
 * @classname AbstractTaskShutdownHook
 * @description [ 任务销毁钩子 ]
 * @date 2021/8/5 16:06
 */
@Slf4j
public abstract class AbstractTaskShutdownHook extends Thread {

    @Getter
    protected AbstractTaskManager abstractTaskManager;

    public AbstractTaskShutdownHook(AbstractTaskManager abstractTaskManager) {
        this.abstractTaskManager = abstractTaskManager;
    }

    @Override
    public void run() {
        log.info(Thread.currentThread().getName() + " 后台任务销毁工作....开始...");
        taskShutdownWork();
        log.info(Thread.currentThread().getName() + " 后台任务销毁工作....结束...");
    }

    /**
     * taskShutdownWork
     */
    protected abstract void taskShutdownWork();
}